from PyQt5.QtWidgets import (QMainWindow, QWidget, QVBoxLayout, 
                                 QStackedWidget, QPushButton, QMessageBox)
from .pages.device_page import DevicePage
from .pages.main_page import MainPage

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("RFID读写程序")
        self.setMinimumSize(800, 600)
        self.setup_ui()

    def setup_ui(self):
        central_widget = QWidget()
        self.setCentralWidget(central_widget)
        layout = QVBoxLayout(central_widget)
        
        # 创建堆叠窗口部件用于页面切换
        self.stacked_widget = QStackedWidget()
        
        # 创建设备选择页面
        self.device_page = DevicePage(self)
        self.stacked_widget.addWidget(self.device_page)
        
        # 创建主操作页面（但暂不显示）
        self.main_page = MainPage(self)
        self.stacked_widget.addWidget(self.main_page)
        
        layout.addWidget(self.stacked_widget)

    def switch_to_main_page(self):
        """切换到主操作页面"""
        self.stacked_widget.setCurrentWidget(self.main_page)

    def show_message(self, title, message):
        QMessageBox.information(self, title, message) 